//
//  LocationTopView.m
//  AILock
//
//  Created by 谭亚明 on 2020/7/27.
//  Copyright © 2020 tym. All rights reserved.
//

#import "LocationTopView.h"
#import "UIButton+Gradient.h"
#import "UIButton+ImageTitleSpacing.h"
@interface LocationTopView()

@property(nonatomic,weak) IBOutlet  UIButton *cityBtn;
@property(nonatomic,weak) IBOutlet UITextField  *nameFid;
@end

@implementation LocationTopView

-(void)awakeFromNib{
    [super awakeFromNib];
    
    [self.cityBtn layoutButtonWithEdgeInsetsStyle:MKButtonEdgeInsetsStyleRight imageTitleSpace:5];
    
    [_nameFid addTarget:self action:@selector(textFieldBeginEditingForB:) forControlEvents:UIControlEventEditingDidEnd];
}

-(void)textFieldBeginEditingForB:(id)sender{
    
    if (self.nameFid.text.length) {
        if (self.editEndBlock) {
            self.editEndBlock(self.nameFid.text);
        }
    }
}

+(LocationTopView*)getLocationTopView{
    return  [[[NSBundle mainBundle] loadNibNamed:@"LocationTopView" owner:self options:nil] lastObject];
}

-(void)setCityStr:(NSString *)cityStr{
    [self.cityBtn setTitle:cityStr forState:UIControlStateNormal];
    [self.cityBtn layoutButtonWithEdgeInsetsStyle:MKButtonEdgeInsetsStyleRight imageTitleSpace:5];
}

-(IBAction)closeAction:(id)sender{
    if (self.closeViewBlock) {
        self.closeViewBlock();
    }
}

-(IBAction)seleCityAction:(id)sender{
    if (self.seleCityBlock) {
        self.seleCityBlock();
    }
}

@end
